<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
		<title>答题</title>
		<link rel="stylesheet" type="text/css" href="../css/main.css" />
		<link rel="stylesheet" type="text/css" href="../css/test_all.css" />
		<script src="../js/rem.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<style type="text/css">
		.pen::-webkit-scrollbar,
		.main_content::-webkit-scrollbar {
			display: none;
		}
		
		.sentence-z {
			top: 80%;
			font-size: 0.9rem;
		}
		
		.making_option_z {
			top: 28%;
		}
	</style>

	<body>
		<div class="listens" id="listens" v-cloak>
			<img src="../img/14@2x.png" width="100%" height="100%" class="background" />
			<div>
				<div class="title">{{listens.test_no}}、{{listens.test_title}}</div>
				<!--听音选词-->
				<div class="main_content" v-if="listens.test_type == 1">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">获取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+test_detail" autoplay></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="comprehension_option">
						<div v-if="chosenState === 1" class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>
					</div>
				</div>
				<!--end听音选词-->
				<!--造句题-->
				<ul class="making_option making_option_z" v-if="listens.test_type == 2">
					<li class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</li>
				</ul>
				<div class="sentence sentence-z" v-if="listens.test_type == 2">
					<span id="words"></span>
				</div>
				<!--end造句题-->
				<!--阅读理解-->
				<div class="sentence" v-if="listens.test_type == 3" v-html="listens.test_detail"></div>
				<div class="comprehension_option" style="margin-top: 20%;" v-if="listens.test_type == 3">
					<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</div>
				</div>
				<!--end阅读理解-->
				<!--词语解析题-->
				<div class="analysis_content analysis_hide" v-if="type == 4">
					<div class="analysis_top">
						<img src="../img/20@2x.png" id="js-play" @click="play()" />
						<span class="analysis1"></span>
						<span class="analysis2"></span>
						<audio src="" id="js-video" class="analysis3">
						</audio>
					</div>
					<div class="analysis_bottom">
						<div class="analysis_bottom_top">
							<p class="analysis4"></p>
							<p class="analysis5"></p>
							<img src="" class="analysis6" />
							<p class="analysis7"></p>
							<p class="analysis8"></p>
						</div>
						<div class="analysis_bottom_middle">
							<img src="../img/20@2x.png" id="js-play2" />
							<span class="analysis9"></span>
							<audio src="" id="js-video2" class="analysis10">
							</audio>
						</div>
						<div class="analysis_bottom_but" @click="analysisNext(end,listens.answer_no,listens.test_id)">
							继续
						</div>
					</div>
				</div>
				<div class="analysis_n" style="display: none;" v-if="type == 4" v-html="listens.test_extend">
				</div>
				<div class="main_content" v-if="type == 4">
					<div class="analysis_option" style="margin-top: 20%;">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							<p>{{index}}</p>
							<img :src="filePath+option" />
						</div>
					</div>
				</div>
				<!--end词语解析题-->
				<!--笔画题-->
				<div class="pen_content" v-if="type == 5">
					<div class="pen">
						<div class="pen_top">
							<img :src="filePath + listens.test_detail" />
						</div>
						<div class="hide_information" v-html="listens.test_extend" v-if="listens.test_extend" style="display: none;">

						</div>
						<div class="stroke"></div>
						<div class="stroke_btn">
							<ul>
								<li v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</li>
							</ul>
						</div>
						<div class="pen_btn next_test" @click="nextTest(end,listens.answer_no,listens.test_id)">
							下一题
						</div>
					</div>
				</div>
				<!--end笔划题-->
				<!--看图选拼音-->
				<div v-if="type == 6">
					<div class="d_img"><img :src="filePath+listens.test_detail" /></div>
					<div class="comprehension_option" style="margin-top: 20%;">
						<div v-if="chosenState === 1" class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>
					</div>
				</div>
				<!--end看图选拼音-->
				<!--录音-->
				<div class="recording_bottom" v-if="type == 7">
					<div class="recording_bottom_top">
						<p>课文内容</p>
						<div v-html="listens.test_detail"></div>
					</div>
					<div class="m-main">
						<div class="audio_img">
							<div id="js-play" @click="play()">
								<img src="../img/20@2x.png" />
								<span>原音</span>
							</div>
							<div class="start_btn">
								<img src="../img/20@2x.png" />
								<span>点击录音</span>
							</div>
							<div class="play_btn">
								<img src="../img/20@2x.png" />
								<span>播放录音</span>
							</div>
						</div>
						<div class="play-box">
							<div class="left">
								<p class="timeline"><span style=""></span></p>
								<div class="info">
									<span class="size">00:00</span>
									<span class="timeshow">读取中</span>
								</div>
							</div>
						</div>
						<div class="video">
							<audio name="media" id="js-video" :src="filePath + listens.test_answer" autoplay="autoplay">
							</audio>
						</div>
					</div>
					<div class="recording_bottom_but" @click="pictureOk(listens.answer_no,listens.test_id)">
						完成
					</div>
				</div>
				<!--end录音-->
				<!--找声母韵母题-->
				<div v-if="type == 8">
					<div class="comprehension_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
					</div>
				</div>
				<!--end找声母韵母题-->
				<!--填空题-->
				<div class="sentence" v-if="type == 9" v-html="listens.test_detail"></div>
				<div class="fill_option" v-if="type == 9">
					<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</div>
				</div>
				<!--end填空题-->
				<!--看图写句子-->
				<div v-if="type == 10">
					<div class="picture_content">
						<div class="picture_content_top">
							<img :src="filePath+listens.test_detail" />
						</div>
						<div class="picture_content_text">
							<textarea placeholder="请输入内容" v-model="sentence"></textarea>
						</div>
						<div class="picture_content_but" @click="pictureOk(listens.answer_no,listens.test_id)">
							完成
						</div>
					</div>
				</div>
				<!--end看图写句子-->
				<!--找声调-->
				<div class="comprehension_option" v-if="type == 11">
					<div v-if="chosenState === 1" class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
						{{option}}
					</div>
					<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
						{{option}}
					</div>
				</div>
				<!--end找声调-->
				<!--音节-->
				<div class="comprehension_option" v-if="type == 12">
					<div v-if="chosenState === 1" class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
						{{option}}
					</div>
					<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
						{{option}}
					</div>
				</div>
				<!--end音节-->
				<!--听音选图-->
				<div class="main_content" v-if="listens.test_type == 13">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">读取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+test_detail" autoplay="autoplay"></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="analysis_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							<p>{{index}}</p>
							<img :src="filePath+option" />
						</div>
					</div>
				</div>
				<!--end听音选图-->
				<!--听音看图选对错-->
				<div class="main_content" v-if="listens.test_type == 14">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">读取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+test_detail" autoplay="autoplay"></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="d_img"><img :src="filePath+listens.test_extend" style="width: 90%;margin-left: -45%;margin-top: 1.5rem;" /></div>
					<div class="judge_option">
						<div @click="choice(listens.answer_option_num,'A',listens.answer_no,listens.test_id)">
							<img src="../img/25@2x.png" />
							<span>错误</span>
						</div>
						<div @click="choice(listens.answer_option_num,'B',listens.answer_no,listens.test_id)">
							<img src="../img/24@2x.png" />
							<span>正确</span>
						</div>
					</div>
				</div>
				<!--end听音看图选对错-->
				<!--看图选词-->
				<div v-if="type == 15">
					<div class="d_img"><img :src="filePath+listens.test_detail" /></div>
					<div class="comprehension_option">
						<div v-if="chosenState === 1" class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>
					</div>
				</div>
				<!--end看图选词-->
				<!--排列句子-->
				<div class="sentence" v-if="type == 16">
					<span id="words"></span>
				</div>
				<ul class="arrange_sentences_option" v-if="type == 16">
					<li class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</li>
				</ul>
				<!--end排列句子-->
				<!--听音组词-->
				<div class="main_content" v-if="listens.test_type == 17">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">读取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+test_detail" autoplay="autoplay"></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="comprehension_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<!--<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>-->
					</div>
				</div>
				<!--end听音组词-->
				<!--看图拼单词-->
				<div v-if="type == 18">
					<div class="d_img"><img :src="filePath+listens.test_detail" /></div>
					<div class="comprehension_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<!--<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>-->
					</div>
				</div>
				<!--end看图拼单词-->
				<!--看图选句子-->
				<div v-if="type == 19">
					<div class="d_img"><img :src="filePath+listens.test_detail" /></div>
					<div class="comprehension_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<!--<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>-->
					</div>
				</div>
				<!--end看图选句子-->
				<!--视频欣赏-->
				<div class="video_content" v-if="type == 20">
					<div class="video_bottom">
						<div class="video_bottom_top">
							<video :src="filePath + test_detail" type="video/mp4" id="video1" width="100%" autoplay="autoplay" muted controls controlslist="nodownload">
							</video>
						</div>
						<div class="video_bottom_middle">
							<div>
								<span>文字翻译</span>
								<span class="translate" @click="translate">翻译</span>
							</div>
							<p class="text" v-html="listens.test_extend"></p>
						</div>
						<div class="video_bottom_but" @click="pictureOk(listens.answer_no,listens.test_id)">
							完成
						</div>
					</div>
				</div>
				<!--end视频欣赏-->
				<!--听音填空-->
				<div class="main_content" style="height: 74%;" v-if="type == 21">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">读取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+listens.test_extend" autoplay="autoplay"></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="sentence" v-html="listens.test_detail" style="width: 100%;margin-left: -50%;"></div>
					<div class="fill_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">{{option}}</div>
					</div>
				</div>
				<!--end	听音填空-->
				<!--计算题-->
				<div v-if="type == 22">
					<div class="sentence">{{listens.test_detail}}</div>
					<div class="comprehension_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							{{option}}
						</div>
						<!--<div v-if="chosenState === 0" class="option" v-for="(option,index) in test_options">
							{{option}}
						</div>-->
					</div>
				</div>
				<!--end计算题-->
				<!--听音看句子选图题-->
				<div class="main_content" v-if="type == 23">
					<div class="audio">
						<div>
							<img src="../img/20@2x.png" id="js-play" @click="play()" />
						</div>
						<div>
							<div class="m-main">
								<div class="play-box">
									<div class="left">
										<p class="timeline"><span style=""></span></p>
										<div class="info">
											<span class="size">00:00</span>
											<span class="timeshow">读取中</span>
										</div>
									</div>
								</div>
								<div class="video">
									<audio name="media" id="js-video" ref="mybox" :src="filePath+listens.test_extend" autoplay="autoplay"></audio>
								</div>
							</div>
						</div>
					</div>
					<div class="sentence">{{listens.test_detail}}</div>
					<div class="analysis_option">
						<div class="option" v-for="(option,index) in test_options" @click="choice(listens.answer_option_num,index,listens.answer_no,listens.test_id,option)">
							<p>{{index}}</p>
							<img :src="filePath+option" />
						</div>
					</div>
				</div>
				<!--end听音看句子选图题-->
			</div>
		</div>
		<div class="fail">
			选择错误&nbsp;请重新选择
		</div>
		<div class="fail_two">
			回答错误
		</div>
		<div class="fail3">
			回答正确
		</div>
		<div class="fail4">
			请录音
		</div>
	</body>
	<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/common.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/jquery-1.9.1.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="../js/jweixin-1.4.0.js" type="text/javascript" charset="utf-8"></script>
	<script src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
	<script type="text/javascript">
		getOpenId(); //获取openid
		paper_id = GetQueryString("id"); //获取url里的id
		var course_type = GetQueryString("course_type"); //课程类别 1淘淘拼音 2YCT 3HSK 4西语发音 5少儿西语 6DELE 7淘转课堂
		var data = {
			state: 0,
			open_id: open_id,
			listens: [],
			test_options: [],
			test_id: 0,
			test_detail: "", //试题内容
			id: 0,
			filePath: filePath, //文件路径
			type: 0, //题型值
			options: [], //需要显示的提型选项
			chosenState: 1, //答题状态
			sentence: "", //句子
			optionsNum: 0, //点击次数
			textIndex: 0,
			asTime: '00:00', //音频初始播放进度
			aeTime: 0, //音频时长
			end: 0, //是否最后一题
			wxData: {
				appId: "",
				timestamp: "",
				nonceStr: "",
				signature: "",
			}, //wx参数
			localId: "", //返回本地的服务器端ID
			serverId: "", //返回音频的服务器端ID
			recording: "", //录音
		}
		var options = [];
		var uuid = uuid(); //生成uuid
		var app = new Vue({
			el: '#listens',
			data: data,
			methods: {
				init: function() {
					var self = this;
					self.getTest();
				},
				//获取试题
				getTest: function() {
					var self = this;
					$.ajax({
						url: apiPath + 'test/get-list',
						type: 'post',
						dataType: 'json',
						data: {
							open_id: open_id,
							paper_id: paper_id,
							flagsign: 1
						},
						success: function(data) {
							self.type = data.returnData.test_type;
							self.listens = data.returnData;
							if(self.type == 9 || self.type == 21) {
								var re = /\[]/g;
								var matches = self.listens.test_detail.match(re) || [];
								for(var j = 0, len = matches.length; j < len; ++j) {
									self.listens.test_detail = self.listens.test_detail.replace(matches[j], '<input id="words" value="" readonly=""></input>');
								}
							}
							if(self.type == 7) {
								self.getWx();
							}
							self.test_options = data.returnData.test_options;
							self.test_detail = data.returnData.test_detail + "?" + data.returnData.test_id;
							self.test_id = data.returnData.test_id;
							self.id = self.id + 1;
							self.chosenState = 1;
						}
					})
				},
				//进行答题，选择选项
				choice: function(answer_option_num, option, answer_no, test_id, index) {
					var self = this;
					self.chosenState = 0;
					if(self.type == 2 || self.type == 16) {
						$("#words").append(index + ' ')
					}
					if(self.type == 4) {
						$(".analysis1").html($(".analysis_n p")[0].innerText);
//						$(".analysis2").html($(".analysis_n p")[2].innerText);
						if($(".analysis_n video")[0]) {
							$(".analysis3").attr("src", $(".analysis_n video")[0].src);
						} else {
							$(".analysis3").attr("src", $(".analysis_n audio")[0].src);
						}
						$(".analysis4").html($(".analysis_n p")[2].innerText);
						$(".analysis5").html($(".analysis_n p")[3].innerText);
						$(".analysis6").attr("src", $(".analysis_n img")[0].src);
						$(".analysis7").html($(".analysis_n p")[5].innerText);
						$(".analysis8").html($(".analysis_n p")[6].innerText);
//						$(".analysis9").html($(".analysis_n p")[9].innerText);
						if($(".analysis_n video")[1]) {
							$(".analysis10").attr("src", $(".analysis_n video")[1].src);
						} else {
							$(".analysis10").attr("src", $(".analysis_n audio")[1].src);
						}
					}
					if(self.type == 5) {
						$(".stroke").append(index)
					}
					if(self.type == 9 || self.type == 21) {
						$(".sentence>p input").eq(self.optionsNum).val(index);
						self.optionsNum++;
					}
					if(answer_option_num > 1 && options.length < answer_option_num) {
						options.push(option);
						if(answer_option_num == options.length) {
							//回答试题
							$.ajax({
								url: apiPath + 'test/answer',
								type: 'post',
								dataType: 'json',
								data: {
									open_id: open_id,
									paper_id: paper_id,
									test_id: test_id,
									answer: options.join(''),
									answer_no: answer_no,
									flagsign: 1
								},
								success: function(data) {
									setTimeout(function() {
										options = [];
										$('.sentence span').html("");
									}, 500);
									var status = data.returnData.is_correct,
										count = data.returnData.answer_num,
										end = data.returnData.is_end;
									self.end = data.returnData.is_end;
									if(end == 1) {
										if(count == 2 && status != 1) {
											$(".fail_two").show();
										} else if(count == 1 && status != 1) {
											$(".fail").show();
										} else if(status == 1) {
											$(".fail3").show();
										}
										if(self.type == "5") {
											$(".pen_top").hide();
											$(".hide_information").show();
											$(".stroke_btn").hide();
											$(".pen_btn").show();
											$(".stroke").hide();
											$(".stroke").html("")
											setTimeout(function() {
												$(".fail3").hide();
											}, 1000);
										} else {
											if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
												setTimeout(function() {
													window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
												}, 3000);
											} else {
												setTimeout(function() {
													window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
												}, 3000);
											}
										}
									} else if(status == 0 && count == 1 && end != 1) {
										self.chosenState = 1;
										$(".stroke").html("");
										setTimeout(function() {
											if(self.type == 9) {
												for(var i = 0; i < self.optionsNum; i++) {
													$(".sentence>p input").eq(i).val("");
												}
												self.optionsNum = 0;
											}
										}, 500);
										$(".fail").show();
										setTimeout(function() {
											$(".fail").hide()
										}, 1000);
									} else if(status == 0 && count == 2 && end != 1) {
										self.chosenState = 1;
										$(".fail_two").show();
										$(".stroke").html("");
										setTimeout(function() {
											if(self.type == 9) {
												for(var i = 0; i < self.optionsNum; i++) {
													$(".sentence>p input").eq(i).val("");
												}
												self.optionsNum = 0;
											}
										}, 500);
										setTimeout(function() {
											$(".fail_two").hide();
											options = [];
											$('.sentence span').html("");
											self.getTest();
											window.location.href = window.location.href
										}, 1000);
									} else if(status == 1 && end != 1) {
										$(".fail3").show();
										if(self.type == "5") {
											$(".pen_top").hide();
											$(".hide_information").show();
											$(".stroke_btn").hide();
											$(".pen_btn").show();
											$(".stroke").hide();
											$(".stroke").html("");
											setTimeout(function() {
												$(".fail3").hide();
											}, 1000);
										} else {
											setTimeout(function() {
												$(".fail3").hide();
												$('.sentence span').html("");
												$(".stroke").html("");
												options = [];
												self.getTest();
												window.location.href = window.location.href
											}, 1000);
										}
									}
								}
							});
						}
					} else if(answer_option_num == 1) {
						//回答试题
						$.ajax({
							url: apiPath + '/test/answer',
							type: 'post',
							dataType: 'json',
							data: {
								open_id: open_id,
								paper_id: paper_id,
								test_id: test_id,
								answer: option,
								answer_no: answer_no,
								flagsign: 1
							},
							success: function(data) {
								var status = data.returnData.is_correct,
									count = data.returnData.answer_num,
									end = data.returnData.is_end;
								self.end = data.returnData.is_end,
									l = 0;
								if(option == 'A') {
									l = 1;
								} else if(option == 'B') {
									l = 2;
								} else if(option == 'C') {
									l = 3;
								} else if(option == 'D') {
									l = 4;
								}
								if((self.type == 4 || self.type == 13 || self.type == 23) && status == 0) {
									$(".analysis_option>div:nth-child(" + l + ")>img").css('border', '1px solid rgb(255,144,0)')
								} else {
									$(".analysis_option>div:nth-child(" + l + ")>img").css('border', '1px solid rgb(113,194,38)')
								}
								if(end == 1 && count == 2 && status != 1) {
									$(".fail_two").show();
									if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
										setTimeout(function() {
											window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									} else {
										setTimeout(function() {
											window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									}
								} else if(end == 1 && status == 1 && self.type != 4) {
									$(".fail3").show();
									if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
										setTimeout(function() {
											window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									} else {
										setTimeout(function() {
											window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									}
								} else if(status == 0 && count == 1) {
									self.chosenState = 1;
									$(".fail").show();
									setTimeout(function() {
										if(self.type == 9) {
											for(var i = 0; i < self.optionsNum; i++) {
												$(".sentence>p input").eq(i).val("");
											}
											self.optionsNum = 0;
										}
									}, 500);
									setTimeout(function() {
										$(".fail").hide()
									}, 1000);
								} else if(status == 0 && count == 2) {
									self.chosenState = 1;
									if(end == 1) {
										$(".fail_two").show();
										setTimeout(function() {
											if(self.type == 9) {
												for(var i = 0; i < self.optionsNum; i++) {
													$(".sentence>p input").eq(i).val("");
												}
												self.optionsNum = 0;
											}
										}, 500);
										setTimeout(function() {
											$(".fail_two").hide();
											if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
												setTimeout(function() {
													window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
												}, 3000);
											} else {
												setTimeout(function() {
													window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
												}, 3000);
											}
										}, 1000);
									} else {
										$(".fail_two").show();
										setTimeout(function() {
											$(".fail_two").hide();
											self.getTest();
											window.location.href = window.location.href
										}, 1000);
									}
								} else if(status == 1) {
									$(".fail3").show();
									if(self.type == "4") {
										$(".title").hide();
										$(".main_content").hide();
										$(".analysis_hide").show();
										setTimeout(function() {
											$(".fail3").hide();
										}, 1000);
									} else {
										setTimeout(function() {
											$(".fail3").hide();
											self.getTest();
											window.location.href = window.location.href
										}, 1000);
									}
								}
							}
						});
					}
				}, //完成试题
				pictureOk: function(answer_no, testId) {
					var self = this;
					var answer = '';
					if(self.type == 7) {
						answer = self.recording;
					}
					if(self.type == 10) {
						answer = self.sentence;
					}
					//回答试题
					$.ajax({
						url: apiPath + '/test/answer',
						type: 'post',
						dataType: 'json',
						data: {
							open_id: open_id,
							paper_id: paper_id,
							test_id: testId,
							answer: answer,
							answer_no: answer_no,
							flagsign: 1
						},
						success: function(data) {
							var end = data.returnData.is_end;
							if(self.type == 7) {
								if(answer == '') {
									alert(self.recording)
									$(".fail4").show();
									setTimeout(function() {
										$(".fail4").hide();
									}, 1000)
								} else {
									if(end == 1) {
										if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
											setTimeout(function() {
												window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
											}, 3000);
										} else {
											setTimeout(function() {
												window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
											}, 3000);
										}
									} else {
										self.getTest()
										window.location.href = window.location.href
									}
								}
							} else {
								if(end == 1) {
									if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
										setTimeout(function() {
											window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									} else {
										setTimeout(function() {
											window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
										}, 3000);
									}
								} else {
									self.getTest()
									window.location.href = window.location.href
								}
							}
						}
					});
				},
				//视频欣赏题翻译
				translate: function() {
					var self = this;
					if(self.textIndex == 0) {
						$(".text").show();
						self.textIndex++
					} else {
						$(".text").hide();
						self.textIndex--
					}
				},
				//下一题
				nextTest: function(end, answer_no) {
					var self = this;
					$(".hide_information").hide();
					$(".pen_top").show();
					$(".hide_information").hide();
					$(".stroke_btn").show();
					$(".pen_btn").hide();
					$(".stroke").show();
					$(".stroke").html("");
					if(end == 1) {
						if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
							setTimeout(function() {
								window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
							}, 3000);
						} else {
							setTimeout(function() {
								window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
							}, 3000);
						}
					} else {
						self.getTest()
						window.location.href = window.location.href
					}
				},
				//词语解析题下一题
				analysisNext: function(end, answer_no) {
					var self = this;
					if(end == 1) {
						if(course_type == 4 || course_type == 5 || course_type == 6 || paper_id == 2) {
							setTimeout(function() {
								window.location.href = path + 'share1.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
							}, 3000);
						} else {
							setTimeout(function() {
								window.location.href = path + 'share2.html?answerno=' + answer_no + "&paperid=" + paper_id + "&course_type=" + course_type
							}, 3000);
						}
					} else {
						self.getTest()
						window.location.href = window.location.href
					}
				},
				//调用微信js-sdk,录音功能
				getWx: function() {
					var self = this;
					$.ajax({
						url: apiPath + 'test/get-jssdk',
						type: 'post',
						dataType: 'json',
						data: {
							open_id: open_id,
							url: document.location.href,
							flagsign: 1
						},
						success: function(data) {
							self.wxData.appId = data.returnData.appId;
							self.wxData.timestamp = data.returnData.timestamp;
							self.wxData.nonceStr = data.returnData.nonceStr;
							self.wxData.signature = data.returnData.signature;
							wx.config({
								debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
								appId: self.wxData.appId, // 必填，公众号的唯一标识
								timestamp: self.wxData.timestamp, // 必填，生成签名的时间戳
								nonceStr: self.wxData.nonceStr, // 必填，生成签名的随机串
								signature: self.wxData.signature, // 必填，签名，见附录1
								jsApiList: ['onMenuShareTimeline', 'onMenuShareAppMessage', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'translateVoice', 'playVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
							});

							wx.ready(function() {
								//录音计时,小于指定秒数(minTime = 10)则设置用户未录音
								var startTime, endTime, minTime = 2;

								//***********************************//
								//开始录音
								$('.start_btn').on('touchstart', function(e) {
									e.preventDefault();
									var $this = $(this);
									$(".start_btn>img").attr("src", "../img/luyin@2x.png");
									startTime = new Date().getTime();
									//开始录音
									wx.startRecord();
								});
								//***********************************//
								//停止录音接口
								$('.start_btn').on('touchend', function() {
									var $this = $(this);
									$(".start_btn>img").attr("src", "../img/20@2x.png");
									//停止录音接口
									wx.stopRecord({
										success: function(res) {
											self.localId = res.localId;
											endTime = new Date().getTime();
											//										alert((endTime - startTime) / 1000);
											if((endTime - startTime) / 1000 < minTime) {
												self.localId = '';
												alert('录音少于' + minTime + '秒，录音失败，请重新录音');
											} else {
												//							var r = confirm("是否确定上传");
												//							if(r == true) {
												wx.uploadVoice({
													//需要上传的音频的本地ID，由 stopRecord 或 onVoiceRecordEnd 接口获得
													localId: self.localId,
													//默认为1，显示进度提示
													isShowProgressTips: 1,
													success: function(res) {
														//返回音频的服务器端ID
														self.serverId = res.serverId;
														var btnArray = ['取消', '确认'];
														self.downLoadVoice();
														//													alert('上传成功')
													}
												});
												//								alert("上传成功");
												//							} else {
												//								alert("请重新录音");
												//							}

											}
										}
									});

								});
								//监听录音自动停止接口
								wx.onVoiceRecordEnd({
									//录音时间超过一分钟没有停止的时候会执行 complete 回调
									complete: function(res) {
										self.localId = res.localId;
										$('.start_btn').removeClass('start_btn_in');

									}
								});

								//***********************************//

								$('.play_btn').on('click', function() {
									if(!self.localId) {
										alert('您还未录音，请录音后再点击播放');
										return;
									}
									var $this = $(this);
									if($this.hasClass('stop_btn')) {
										$(this).removeClass('stop_btn');
										$(".play_btn>span").text('点我播放');

										//		//暂停播放接口
										//		wx.pauseVoice({
										//			//需要暂停的音频的本地ID，由 stopRecord 或 onVoiceRecordEnd 接口获得
										//			localId: localId
										//		});

										//停止播放接口
										wx.stopVoice({
											//需要停止的音频的本地ID，由 stopRecord 或 onVoiceRecordEnd 接口获得
											localId: self.localId
										});
									} else {
										$this.addClass('stop_btn');
										$(".play_btn>span").text('点我停止')
										//播放语音接口
										wx.playVoice({
											//需要播放的音频的本地ID，由 stopRecord 或 onVoiceRecordEnd 接口获得
											localId: self.localId
										});
									}
								});
								//监听语音播放完毕接口
								wx.onVoicePlayEnd({
									//需要下载的音频的服务器端ID，由uploadVoice接口获得
									serverId: self.localId,
									success: function(res) {
										$('.play_btn').removeClass('stop_btn');
										$(".play_btn>span").text('点我播放')
										//返回音频的本地ID
										//localId = res.localId;
									}
								});

							});
						}
					})
				},
				//上传录音ID
				downLoadVoice: function() {
					var self = this;
					$.ajax({
						url: apiPath + 'test/upload',
						type: 'post',
						dataType: 'json',
						data: {
							open_id: open_id,
							media_id: self.serverId,
							flagsign: 1
						},
						success: function(data) {
							self.recording = data.returnData.path;
						}
					})
				},
				//播放音频
				play: function() {
					var audio = $("#js-video")[0];
					if(audio.paused) {
						audio.play();
					} else {
						audio.pause();
					}
				}
			},
			updated: function() {
				var self = this;
				if($("#js-video")[0] && self.state == 0) {
					self.state = 1;
					self.play();
					var audio = $("#js-video")[0];
					if(audio.paused) {
						$("#js-play").click()
					}
					var timeid = setInterval(function() {
						var currentTime = audio.currentTime;
						if(audio.duration) {
							aL();
						}
						setTimeShow(currentTime);
					}, 200);

					function aL() {
						if(audio.duration) {
							$('.timeshow').text(secondToMin(audio.duration));
						}
					}
					// 设置播放时间
					function setTimeShow(t) {
						t = Math.floor(t);
						var playTime = secondToMin(audio.currentTime);
						$(".size").html(playTime);
						$('.timeline').children().css({
							width: (t / parseInt(audio.duration)).toFixed(4) * 100 + "%"
						});
					};
					// 计算时间
					function secondToMin(s) {
						var MM = Math.floor(s / 60);
						var SS = s % 60;
						if(MM < 10)
							MM = "0" + MM;
						if(SS < 10)
							SS = "0" + SS;
						var min = MM + ":" + SS;
						return min.split('.')[0];
					};
				}
				AudioControl('js-video2')

				function AudioControl(id) {
					// 音频控制进度条
					var audio = document.getElementById(id);
					var index = 0;
					$(audio).on('loadedmetadata', function() {
						audio.pause();
						// 播放
						$(document).on('click', '#js-play2', function() {
							if(index == 0) {
								audio.play();
								index++;
							} else if(index == 1) {
								audio.pause();
								index--;
							}

						});
					});
				}
			},
			mounted: function() {
				var self = this; //判断音频是否存在
				// 兼容Android 键盘弹起时,影响布局
				var h = document.body.scrollHeight // 用onresize事件监控窗口或框架被调整大小，先把一开始的高度记录下来
				window.onresize = function() { // 如果当前窗口小于一开始记录的窗口高度，那就让当前窗口等于一开始窗口的高度
					if(document.body.scrollHeight < h) {
						document.body.style.height = h + "px"
					}
				};
				var url = 'ws://47.112.96.233:2000';
				socket = new WebSocket(url);
				socket.onopen = function() {
					var content = JSON.stringify({
						type: "in",
						open_id: open_id
					});
					socket.send(content);
				}
			}
		})
		app.init();
		document.addEventListener("WeixinJSBridgeReady", function() {
			var aPlay = setInterval(paly, 500);

			function paly() {
				if($("#js-video")[0]) {
					$("#js-video")[0].play();
					clearInterval(aPlay);
				}
			}
		}, false);
	</script>
	<script type="text/javascript">
		var index = 0,
			a = 0;
		//笔划题显示点击笔划选项
		$(".stroke_btn>ul>li").click(function() {
			a++;
			index = $(this).index();
			$(".stroke").append($(".stroke_btn>ul>li").eq(index).html())
			if(a == 5) {
				$(".hide_information").show()
			}
		});
	</script>

</html>